<?php

require_once 'database_engine/commands.php';
require_once 'database_engine/common_engine.php';

class EditableDataset implements IDataset
{
    /** @var \IConnection */
    private $connection;

    /** @var \DataSourceMetadata */
    private $datasetMetadata;

    /** @var \SelectCommand */
    private $selectCommand;

    /** @var IDataReader */
    private $dataReader;

    public function __construct(IConnection $connection, DataSourceMetadata $datasetMetadata)
    {
        $this->connection = $connection;
        $this->datasetMetadata = $datasetMetadata;

        $this->selectCommand = new SelectCommand();
        $this->selectCommand->AddSource($this->datasetMetadata, '[default_table]');

        $this->dataReader = null;
    }

    function AddSimpleCondition($fieldName, ConditionOperator $operator, $value)
    {
        $this->selectCommand->AddSimpleCondition($fieldName, $operator, $value);
    }

    /**
     * @return void
     */
    function Close()
    {
        $this->dataReader->Close();
    }

    /**
     * @return string[]
     */
    function GetFieldNames()
    {
        // TODO: Implement GetFieldNames() method.
    }

    /**
     * @param string $fieldName
     * @return mixed
     */
    function GetFieldValueByName($fieldName)
    {
        // TODO: Implement GetFieldValueByName() method.
    }

    /**
     * @param string $fieldName
     * @return boolean
     */
    function IsPrimaryKeyField($fieldName)
    {
        // TODO: Implement IsPrimaryKeyField() method.
    }

    /**
     * @return boolean
     */
    function Next()
    {
        return $this->dataReader->Next();
    }

    /**
     * @return void
     */
    function Open()
    {
        $this->dataReader = $this->selectCommand->ExecuteReader($this->connection);
    }

    /**
     * @param string $fieldName
     * @param mixed $value
     * @return void
     */
    function SetFieldValueByName($fieldName, $value)
    {
        // TODO: Implement SetFieldValueByName() method.
    }

    /**
     * @param string $fieldName
     * @param string $fileName
     * @return void
     */
    function SetFieldValueByNameAsFileName($fieldName, $fileName)
    {
        // TODO: Implement SetFieldValueByNameAsFileName() method.
    }

    /**
     * @return void
     */
    function Edit() {
        // TODO: Implement Edit() method.
    }

    /**
     * @return void
     */
    function Post() {
        // TODO: Implement Post() method.
    }

    /**
     * @return void
     */
    function Insert()
    {
        // TODO: Implement Insert() method.
    }
}

?>